package com.study.guide.codec.MessagePack;
import org.msgpack.MessagePack;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * 	自定义编码器
 * @author nrzt
 *
 */
public class MsgpackEncoder extends MessageToByteEncoder<Object>{

	@Override
	protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
		MessagePack msgpack=new MessagePack();
        byte[] raw=msgpack.write(msg);
        out.writeBytes(raw);
	}

}
